package cc.rboot._core.helper;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;

import java.lang.reflect.Method;

public class MethodHelper {
    public static Method get(ProceedingJoinPoint joinPoint) {
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        Method targetMethod = methodSignature.getMethod();

        return targetMethod;
    }

    public static Method get(ProceedingJoinPoint joinPoint, String methodName) throws NoSuchMethodException {
        MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
        Method targetMethod = methodSignature.getMethod();
        return joinPoint.getTarget().getClass().getMethod(methodName, targetMethod.getParameterTypes());
    }
}
